import request from "@/utils/request";

export function addTestPaper(testPaper) {
    return request({
        url: '/testPaper/addTestPaper',
        method: 'post',
        data: testPaper
    })
}

export function deleteTestPaper(ids) {
    return request({
        url: '/testPaper/deleteTestPaper',
        method: 'delete',
        data: ids
    })
}

export function changeTestPaper(testPaper) {
    return request({
        url: '/testPaper/updateTestPaper',
        method: 'post',
        data: testPaper
    })
}

export function getAllTestPaper(testPaper, page, pageSize) {
    return request({
        url: '/testPaper/getAllTestPaper?' + 'page=' + page + '&pageSize=' + pageSize,
        method: 'post',
        data: testPaper
    })
}

export function getTestPaper(trainingPlanId) {
    return request({
        url: '/testPaper/getTestPaper?trainingPlanId='+trainingPlanId,
        method: 'get',
    })
}


export function getTestQuestion(trainingPlanId, searchChoose) {
    let choose = 1;
    if (searchChoose) {
        choose = 0
    }
    return request({
        url: '/testPaper/getTestQuestion?trainingPlanId=' + trainingPlanId + "&choose=" + choose,
        method: 'get',
    })
}

export function chooseQuestions(ids, trainingPlanId) {
    return request({
        url: '/testPaper/chooseQuestions?trainingPlanId=' + trainingPlanId,
        method: 'post',
        data:ids
    })
}
export function unchooseQuestions(ids, trainingPlanId) {
    return request({
        url: '/testPaper/unchooseQuestions?trainingPlanId=' + trainingPlanId,
        method: 'post',
        data:ids
    })
}


export function getTestQuestionListForTest(trainingPlanId) {
    return request({
        url: '/testPaper/getTestQuestionListForTest?trainingPlanId=' + trainingPlanId ,
        method: 'get',
    })
}

export function updateScore(trainingPlanId,testQuestionId,score) {
    return request({
        url: '/testPaper/updateScore?trainingPlanId=' + trainingPlanId +"&testQuestionId="+testQuestionId+"&score="+score,
        method: 'post',
    })
}

export function getScore(trainingPlanId,testQuestionId,score) {
    return request({
        url: '/testPaper/getScore?trainingPlanId=' + trainingPlanId +"&testQuestionId="+testQuestionId,
        method: 'get',
    })
}

export function selectedQuestionAndScore(trainingPlanId) {
    return request({
        url: '/testPaper/selectedQuestionAndScore?trainingPlanId=' + trainingPlanId ,
        method: 'get',
    })
}

